/******************************************************
* Team WB
* Brett Cate, William Kim
* 
* Register File ADT Header
*******************************************************/

#ifndef SC2_H
#include "sc2.h"
#endif
#ifndef REGISTER16_H
#include "register16.h"
#endif

#ifndef REGISTERFILE_H
#define REGISTERFILE_H

#define REGISTER_COUNT 16
#define $R0 0
#define $R1 1
#define $R2 2
#define $R3 3
#define $R4 4
#define $R5 5
#define $R6 6
#define $R7 7
#define $R8 8
#define $R9 9
#define $RA 0xA
#define $RB 0xB
#define $RC 0xC
#define $RD 0xD
#define $RE 0xE
#define $RF 0xF

typedef RegisterPtr* RegisterFilePtr;

/*
Creates a new register file, containing 16 register pointers in an array.

return value: A pointer to an array of 16 registers.
*/
RegisterFilePtr registerFile_new();

/*
Returns the selected byte from the given register.

parameter (the_register_file): The register file whose register the byte comes from.
parameter (the_register_number): The register number for the register whose byte is returned.
parameter (the_selected_byte): The number of the byte to return from the register. 
Either 1 (high byte) or 0 (low byte).

parameter (*the_error): Pointer to the int value of the error code for this function.

return value: A uchar containing the value of the byte chosen in the selected register.

*/
uchar registerFile_getByteFrom(RegisterFilePtr the_register_file,
							   int the_register_number, int the_selected_byte,
							   int* the_error);

/*
Puts the given byte into the register indicated in the given register file, 
and returns the int value of the error code for this function.

parameter (the_register_file): The register file into whose register the byte is put.
parameter (the_register_number): The number of the register where the byte is put.
parameter (the_selected_byte): The number of the byte, either 1 for high order or 0 for 
low order, where the given value is placed.

parameter (the_byte): The value to put in the indicated register.

return value: The int value of the error code for this function.
*/
int registerFile_putByteTo(RegisterFilePtr the_register_file, int the_register_number,
						   int the_selected_byte, uchar the_byte);

/*
Returns the value of the indicated register in the given register file.

parameter (the_register_file): The register file whose register value is returned.
parameter (the_register_number): The number of the register whose value is returned.
parameter (*the_error): Pointer to the int value of the error code for this function.

return value: A ushort containing the value of the indicated register in the given register file.
*/
ushort registerFile_getRegValue(RegisterFilePtr the_register_file,
								int the_register_number, int* the_error);

/*
Puts the given value into the indicated register of the given register file and 
returns the int value of the error code for this function.

parameter (the_register_file): The register file into whose register the value is put.
parameter (the_register_number): The number of the register whose value is changed.
parameter (the_value): The value which is put into the indicated register.

return value: The int value of the error code for this function.
*/
int registerFile_putRegValue(RegisterFilePtr the_register_file, int the_register_number, ushort the_value);

#endif

/* End Program */
